// defHttp就是封装好的发送请求函数
import { defHttp } from '/@/utils/http/axios';
// 数据类型 - 定义响应返回值数据的类型
import { CategoryListModel } from './model/categoryModel';

// 枚举：定义请求地址的
enum Api {
  GetCategory1List = '/admin/product/getCategory1',
  GetCategory2List = '/admin/product/getCategory2',
  GetCategory3List = '/admin/product/getCategory3',
}

// 获取1级分类列表
export const getCategory1ListApi = () => {
  return defHttp.get<CategoryListModel>({
    url: Api.GetCategory1List,
  });
};

// 获取2级分类列表
export const getCategory2ListApi = (category1Id: number) => {
  return defHttp.get<CategoryListModel>({
    url: Api.GetCategory2List,
    params: `/${category1Id}`,
  });
};

// 获取3级分类列表
export const getCategory3ListApi = (category2Id: number) => {
  return defHttp.get<CategoryListModel>({
    url: Api.GetCategory3List,
    params: `/${category2Id}`,
  });
};
